// 手机号校验
export const validPhone = phone => {
	if (
		!
		/^((13[0-9])|(14[5-9])|(15([0-3]|[5-9]))|(16[6-7])|(17[1-8])|(18[0-9])|(19[1|3])|(19[5|6])|(19[8|9]))\d{8}$/
		.test(
			phone
		)
	) {
		return false
	} else {
		return true
	}
}


export function debounce(fn, wait, immediate) {
	let timer;
	return function() {
		if (timer) clearTimeout(timer)
		if (immediate) {
			let callNow = !timer
			timer = setTimeout(() => {
				timer = null
			}, wait)
			if (callNow) {
				fn.apply(this, arguments)
			}
		} else {
			timer = setTimeout(() => {
				fn.apply(this, arguments)
			}, wait)
		}
	}
}
// export const debounce = (fn, wait, immediate) => {
// 	console.log('??')
// 	let timer;
// 	return function() {
// 		console.log("??!")
// 		if (timer) clearTimeout(timer)
// 		if (immediate) {
// 			let callNow = !timer
// 			timer = setTimeout(() => {
// 				timer = null
// 			}, wait)
// 			if (callNow) {
// 				fn.apply(this, arguments)
// 			}
// 		} else {
// 			timer = setTimeout(() => {
// 				console.log(fn)
// 				fn.apply(this, arguments)
// 			}, wait)
// 		}
// 	}
// }
